package com.ldzy.dao;

import com.github.pagehelper.Page;
import com.ldzy.pojo.Medicine;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface MedicineMapper {
    @Select("<script>"+"select* from medicine <where>" +
            "<if test=\"name != null\"> AND  name like  CONCAT('%',#{name},'%')</if>" +
            "<if test=\"efficacy != null\"> AND efficacy like  CONCAT('%', #{efficacy},'%')</if>" +
            "</where>"+
            "order by mid "+"</script>")
    Page<Medicine> search(Medicine m);
    @Delete("delete from medicine where mid=#{mid}")
    int deleteMd(@Param("mid") Integer mid);
    @Select("select*from medicine")
    Page<Medicine> all();
    @Select("select * from medicine where mid=#{mid}")
    Medicine get(int id);
    @Update("update medicine set count=#{count} where mid=#{mid}")
    void updateById(Medicine medicine);
    @Insert("insert into medicine(name,mode,efficacy,price,count) values(#{name},#{mode},#{efficacy},#{price},#{count})")
    int addMedicine(Medicine medicine);
}
